/**
 * 初始化手术详情对话框
 */
var CdcSurgeryInfoDlg = {
    validateFields: {
    	episodeId: {
            validators: {
                notEmpty: {
                    message: '就诊记录不能为空'
                }
            }
        },
    	description: {
            validators: {
                notEmpty: {
                    message: '描述不能为空'
                }
            }
        },
    	code: {
            validators: {
                notEmpty: {
                    message: '编码不能为空'
                }
            }
        },
    	busSurgTypeId: {
            validators: {
                notEmpty: {
                    message: '类型不能为空'
                }
            }
        },
    	busSurgStatusId: {
            validators: {
                notEmpty: {
                    message: '状态不能为空'
                }
            }
        },
    	startDate: {
            validators: {
                notEmpty: {
                    message: '手术开始日期不能为空'
                }
            }
        },
    	endDate: {
            validators: {
                notEmpty: {
                    message: '手术结束日期不能为空'
                }
            }
        },
    	surgLocId: {
            validators: {
                notEmpty: {
                    message: '科室不能为空'
                }
            }
        },
    	surgDocId: {
            validators: {
                notEmpty: {
                    message: '主刀医生不能为空'
                }
            }
        },
    	assi1stId: {
            validators: {
                notEmpty: {
                    message: '一助不能为空'
                }
            }
        },
    	assi2ndId: {
            validators: {
                notEmpty: {
                    message: '二助不能为空'
                }
            }
        },
    	busSurgInciId: {
            validators: {
                notEmpty: {
                    message: '切口等级不能为空'
                }
            }
        },
    	busSurgHealId: {
            validators: {
                notEmpty: {
                    message: '愈合情况不能为空'
                }
            }
        },
    	busSurgAnesId: {
            validators: {
                notEmpty: {
                    message: '麻醉方式不能为空'
                }
            }
        },
    	anesDocId: {
            validators: {
                notEmpty: {
                    message: '麻醉医生不能为空'
                }
            }
        },
    	asaScore: {
            validators: {
                notEmpty: {
                    message: 'ASA评分不能为空'
                }
            }
        },
    	nnisGrade: {
            validators: {
                notEmpty: {
                    message: 'NNIS分级不能为空'
                }
            }
        },
    	wbcCount: {
            validators: {
                notEmpty: {
                    message: '术前外周WBC计数不能为空'
                }
            }
        },
    	inciCount: {
            validators: {
                notEmpty: {
                    message: '切口个数不能为空'
                }
            }
        },
    	isEndoscope: {
            validators: {
                notEmpty: {
                    message: '是否使用窥镜不能为空'
                }
            }
        },
    	isImplants: {
            validators: {
                notEmpty: {
                    message: '是否有植入物不能为空'
                }
            }
        },
    	bloodLose: {
            validators: {
                notEmpty: {
                    message: '失血量不能为空'
                }
            }
        },
    	bloodGet: {
            validators: {
                notEmpty: {
                    message: '输血量不能为空'
                }
            }
        },
    	complication: {
            validators: {
                notEmpty: {
                    message: '术后并发症不能为空'
                }
            }
        },
    	dataId: {
            validators: {
                notEmpty: {
                    message: '业务数据类型不能为空'
                }
            }
        },
    	isActive: {
            validators: {
                notEmpty: {
                    message: '是否有效不能为空'
                }
            }
        },
    }
};


/**
 * 关闭此对话框
 */
CdcSurgeryInfoDlg.close = function() {
    parent.layer.close(parent.layer.getFrameIndex(window.name)); //先得到当前iframe层的索引,再执行关闭   
}

/**
 * 验证数据是否为空
 */
CdcSurgeryInfoDlg.validate = function () {
    $('#cdcSurgeryInfoForm').data("bootstrapValidator").resetForm();
    $('#cdcSurgeryInfoForm').bootstrapValidator('validate');
    return $("#cdcSurgeryInfoForm").data('bootstrapValidator').isValid();
}

/**
 * 提交新增
 */
CdcSurgeryInfoDlg.addSubmit = function() {

    if (!this.validate()) {
        return;
    }
    //提交信息
    Sys.ajaxForm('cdcSurgeryInfoForm',Sys.backendPath + "/cdc/cdcsurgery/add",function(res) {
        Sys.success(res.message);
    	window.parent.CdcSurgery.table.refresh();
        CdcSurgeryInfoDlg.close();
    });
}

/**
 * 提交修改
 */
CdcSurgeryInfoDlg.editSubmit = function() {

    if (!this.validate()) {
        return;
    }
    //提交信息
    Sys.ajaxForm('cdcSurgeryInfoForm',Sys.backendPath + "/cdc/cdcsurgery/update",function(res) {
        Sys.success(res.message);
    	window.parent.CdcSurgery.table.refresh();
        CdcSurgeryInfoDlg.close();
    });
}

$(function() {
	Sys.initValidator("cdcSurgeryInfoForm", CdcSurgeryInfoDlg.validateFields);
});
